#ifndef BALL_FREE_H
#define BALL_FREE_H
#include "common.h"
#include "data_structure.h"

#include <math.h>
#include "frog.h"

class Ball_free {
	friend class Frog;
	friend class Ball_in_line;
	friend class Balls_list;
public:
	Ball_free() = default;
	Ball_free(int x, int y, double angle, color_t color) :
		x(x), y(y), angle(angle), color(color)
	{ x_true = x; y_true = y;}
	
	void move()
	{
		x_true += BALL_FREE_MOVE_SPEED * cos(angle);
		y_true += BALL_FREE_MOVE_SPEED * sin(angle);
		x = (int)x_true;
		y = (int)y_true;
	}

	bool check_out_of_screen()
	{
		if (x <= 0 || x >= SCREEN_WIDTH)
			return true;
		else if (y <= 0 || y >= SCREEN_HEIGHT)
			return true;
		else
			return false;
	}

	void draw()
	{
		setfillcolor(color);
		fillellipse(x, y, BALL_RADIUS, BALL_RADIUS);
	}
private:
	int x;
	int y;
	double x_true;
	double y_true;
	double angle;
	color_t color;
};
#endif